package com.freemyleft.left.left_app.mian.index.work.completecoures;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.freemyleft.left.left_app.mian.index.work.waitingforclass.adapter.WaitingForClassFiles;
import com.freemyleft.left.zapp.ui.recycler.DataConverter;
import com.freemyleft.left.zapp.ui.recycler.MultipleFields;
import com.freemyleft.left.zapp.ui.recycler.MultipleItemEntity;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;

import java.util.ArrayList;

public class CopleteCourseConvert extends DataConverter {
    ArrayList<MultipleItemEntity> bean = new ArrayList<>();
    @Override
    public ArrayList<MultipleItemEntity> convert() {
        JSONObject object=JSONObject.parseObject(getJsonData());
        JSONArray result=object.getJSONArray("result");
        int size=result.size();
        for (int j = 0; j <size ; j++) {
            JSONObject object2=result.getJSONObject(j);
            String id=object2.getString("id");
            String type=String.valueOf(object2.getString("type"));
            String grade=object2.getString("grade");//年级
            String subject=object2.getString("subject");//科目
            String head=object2.getString("head");//头像
            String addr=object2.getString("addr");//（评价详情为空可评价）
            String price=object2.getString("price");//价格
            String date1=object2.getString("date");//日期啊
            String time=object2.getString("time");//上课时间
            String from=object2.getString("from");//来源
            String status=object2.getString("status");//状态
            String phone=object2.getString("phone");//电话
            String studentid=object2.getString("studentid");//学生id
            String startime=object2.getString("startime");//开始时间
            String studentname=object2.getString("studentname");//学生姓名
            String homework=object2.getString("homework");//是否有课前作业
            String prehomework=object2.getString("prehomework");//作业名称
            MultipleItemEntity entity=MultipleItemEntity.builder()
                    .setField(MultipleFields.ITEM_TYPE,1)
                    .setField(WaitingForClassFiles.LOCATION,addr)
                    .setField(WaitingForClassFiles.DATE,date1+"  "+time)
                    .setField(WaitingForClassFiles.PRICE,price)
                    .setField(WaitingForClassFiles.STATUS,status)
                    .setField(WaitingForClassFiles.HEAD,head)
                    .setField(WaitingForClassFiles.STUDENT_MESSAGE,studentname+" "+subject+" "+grade)
                    .setField(WaitingForClassFiles.TYPE,type)
                    .build();
            bean.add(entity);
        }
        return bean;
    }

}


